package conf

import "fmt"

type app struct {
	Mode           string
	CaptchaEnable  bool
	RegisterEnable bool
}

var App = app{
	Mode:           "release",
	CaptchaEnable:  true,
	RegisterEnable: true,
}

func SetRegisterEnable(enable bool) error {
	cfg.Section("App").Key("RegisterEnable").SetValue(fmt.Sprintf("%v", enable))
	if err := save(); err != nil {
		return err
	}
	App.RegisterEnable = enable
	return nil
}

func SetCaptchaEnable(enable bool) error {
	cfg.Section("App").Key("CaptchaEnable").SetValue(fmt.Sprintf("%v", enable))
	if err := save(); err != nil {
		return err
	}
	App.CaptchaEnable = enable
	return nil
}
